package com.sun.showcase.biz.mall.job;

import com.sun.showcase.biz.mall.service.MemberBillService;
import com.sun.showcase.biz.mall.service.OrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component("mallJob")
public class MallJob {
	private Logger logger = LoggerFactory.getLogger(getClass());
	@Autowired
	private OrderService orderService;
	@Autowired
	private MemberBillService memberBillService;
	/**
	 * 根据系统配置，已发货订单，超出指定时间自动完成
	 * 
	 */
	public void autoCompeleteOrder() {
		try {
			orderService.autoCompeleteOrder();
		} catch (Exception e) {
			logger.error("订单自动确认收货异常，{}",e.getMessage());
		}
	}
	
	/**
	 * 商家结算，订单超过平台配置的可退货期限后,增加商家余额
	 * 
	 */
	public void settle() {
		try {
			orderService.settleOrder();
		} catch (Exception e) {
			logger.error("订单自动确认收货异常，{}",e.getMessage());
		}
	}
	
	/**
	 * 释放会员冻结金额，订单超过平台配置的可退货期限后。
	 */
	public void memberBill() {
		try {
			memberBillService.dealBillJob();
		} catch (Exception e) {
			logger.error("会员冻结金额处理异常，{}",e.getMessage());
		}
	}
}
